home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / ETC / TEXINFO < prev    next >
Text File  |  1991-03-31  |  79KB  |  2,500 lines

  1. %% TeX macros to handle texinfo files
  2.  
  3. %   Copyright (C) 1985, 1986, 1988, 1990 Free Software Foundation, Inc.
  4.  
  5. %This texinfo.tex file is free software; you can redistribute it and/or
  6. %modify it under the terms of the GNU General Public License as
  7. %published by the Free Software Foundation; either version 1, or (at
  8. %your option) any later version.
  9.  
  10. %This texinfo.tex file is distributed in the hope that it will be
  11. %useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  12. %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. %General Public License for more details.
  14.  
  15. %You should have received a copy of the GNU General Public License
  16. %along with this texinfo.tex file; see the file COPYING.  If not, write
  17. %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  18. %USA.
  19.  
  20.  
  21. %In other words, you are welcome to use, share and improve this program.
  22. %You are forbidden to forbid anyone else to use, share and improve
  23. %what you give them.   Help stamp out software-hoarding!
  24.  
  25. \def\texinfoversion{2.13}
  26. \message{Loading texinfo package [Version \texinfoversion]:}
  27. \message{}
  28.  
  29. % Print the version number if in a .fmt file.
  30. \everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
  31.  
  32. % Save some parts of plain tex whose names we will redefine.
  33.  
  34. \let\ptexlbrace=\{
  35. \let\ptexrbrace=\}
  36. \let\ptexdot=\.
  37. \let\ptexstar=\*
  38. \let\ptexend=\end
  39. \let\ptexbullet=\bullet
  40. \let\ptexb=\b
  41. \let\ptexc=\c
  42. \let\ptexi=\i
  43. \let\ptext=\t
  44. \let\ptexl=\l
  45. \let\ptexL=\L
  46.  
  47. \def\tie{\penalty 10000\ }     % Save plain tex definition of ~.
  48.  
  49. \message{Basics,}
  50. \chardef\other=12
  51.  
  52. \hyphenation{ap-pen-dix}
  53. \hyphenation{mini-buf-fer mini-buf-fers}
  54. \hyphenation{eshell}
  55.  
  56. % Margin to add to right of even pages, to left of odd pages.
  57. \newdimen \bindingoffset  \bindingoffset=0pt
  58. \newdimen \normaloffset   \normaloffset=\hoffset
  59. \newdimen\pagewidth \newdimen\pageheight
  60. \pagewidth=\hsize \pageheight=\vsize
  61.  
  62. %---------------------Begin change-----------------------
  63. %
  64. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
  65. %
  66. \newdimen\cornerlong \newdimen\cornerthick
  67. \newdimen \topandbottommargin
  68. \newdimen \outerhsize \newdimen \outervsize
  69. \cornerlong=1pc\cornerthick=.3pt        % These set size of cropmarks
  70. \outerhsize=7in
  71. \outervsize=9.5in
  72. \topandbottommargin=.75in
  73. %
  74. %---------------------End change-----------------------
  75.  
  76. % \onepageout takes a vbox as an argument.  Note that \pagecontents
  77. % does insertions itself, but you have to call it yourself.
  78. \chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
  79. \def\onepageout#1{\hoffset=\normaloffset
  80. \ifodd\pageno  \advance\hoffset by \bindingoffset
  81. \else \advance\hoffset by -\bindingoffset\fi
  82. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  83. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
  84. {\let\hsize=\pagewidth \makefootline}}}%
  85. \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  86.  
  87.  
  88. % Here is a modification of the main output routine for Near East Publications
  89. % This provides right-angle cropmarks at all four corners.
  90. % The contents of the page are centerlined into the cropmarks,
  91. % and any desired binding offset is added as an \hskip on either
  92. % site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
  93. %
  94. \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
  95.                  \shipout
  96.                  \vbox to \outervsize{\hsize=\outerhsize
  97.                  \vbox{\line{\ewtop\hfill\ewtop}}
  98.                  \nointerlineskip
  99.                  \line{\vbox{\moveleft\cornerthick\nstop}
  100.                        \hfill
  101.                        \vbox{\moveright\cornerthick\nstop}}
  102.                  \vskip \topandbottommargin
  103.                  \centerline{\ifodd\pageno\hskip\bindingoffset\fi
  104.                         \vbox{
  105.                         {\let\hsize=\pagewidth \makeheadline}
  106.                         \pagebody{#1}
  107.                         {\let\hsize=\pagewidth \makefootline}}
  108.                         \ifodd\pageno\else\hskip\bindingoffset\fi}
  109.                  \vskip \topandbottommargin plus1fill minus1fill
  110.                  \boxmaxdepth\cornerthick
  111.                  \line{\vbox{\moveleft\cornerthick\nsbot}
  112.                        \hfill
  113.                        \vbox{\moveright\cornerthick\nsbot}}
  114.                  \nointerlineskip
  115.                  \vbox{\line{\ewbot\hfill\ewbot}}
  116.         }
  117.   \advancepageno 
  118.   \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  119. %
  120. % Do @cropmarks to get crop marks
  121. \def\cropmarks{\let\onepageout=\croppageout }
  122.  
  123. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  124. {\catcode`\@ =11
  125. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  126. \dimen@=\dp#1 \unvbox#1
  127. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  128. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  129. }
  130.  
  131. %
  132. % Here are the rules for the cropmarks.  Note that they are
  133. % offset so that the space between them is truly \outerhsize or \outervsize
  134. % (P. A. MacKay, 12 November, 1986)
  135. %
  136. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  137. \def\nstop{\vbox
  138.   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  139. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  140. \def\nsbot{\vbox
  141.   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  142.  
  143. % Parse an argument, then pass it to #1.
  144. % The argument can be delimited with [...] or with "..." or braces
  145. % or it can be a whole line.
  146. % #1 should be a macro which expects
  147. % an ordinary undelimited TeX argument.
  148.  
  149. \def\parsearg #1{\let\next=#1\begingroup\obeylines\futurelet\temp\parseargx}
  150.  
  151. \def\parseargx{%
  152. \ifx \obeyedspace\temp \aftergroup\parseargdiscardspace \else%
  153. \aftergroup \parseargline %
  154. \fi \endgroup}
  155.  
  156. {\obeyspaces %
  157. \gdef\parseargdiscardspace {\begingroup\obeylines\futurelet\temp\parseargx}}
  158.  
  159. \gdef\obeyedspace{\ }
  160.  
  161. \def\parseargline{\begingroup \obeylines \parsearglinex}
  162. {\obeylines %
  163. \gdef\parsearglinex #1^^M{\endgroup \next {#1}}}
  164.  
  165. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  166.  
  167. %% These are used to keep @begin/@end levels from running away
  168. %% Call \inENV within environments (after a \begingroup)
  169. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  170. \def\ENVcheck{%
  171. \ifENV\errmessage{Still within an environment.  Type Return to continue.}
  172. \endgroup\fi} % This is not perfect, but it should reduce lossage
  173.  
  174. % @begin foo  is the same as @foo, for now.
  175. \newhelp\EMsimple{Type <Return> to continue}
  176.  
  177. \outer\def\begin{\parsearg\beginxxx}
  178.  
  179. \def\beginxxx #1{%
  180. \expandafter\ifx\csname #1\endcsname\relax
  181. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  182. \csname #1\endcsname\fi}
  183.  
  184. %% @end foo executes the definition of \Efoo.
  185. %% foo can be delimited by doublequotes or brackets.
  186.  
  187. \def\end{\parsearg\endxxx}
  188.  
  189. \def\endxxx #1{%
  190. \expandafter\ifx\csname E#1\endcsname\relax
  191. \expandafter\ifx\csname #1\endcsname\relax
  192. \errmessage{Undefined command @end #1}\else
  193. \errorE{#1}\fi\fi
  194. \csname E#1\endcsname}
  195. \def\errorE#1{
  196. {\errhelp=\EMsimple \errmessage{@end #1 not within #1 environment}}}
  197.  
  198. % Single-spacing is done by various environments.
  199.  
  200. \newskip\singlespaceskip \singlespaceskip = \baselineskip
  201. \def\singlespace{%
  202. {\advance \baselineskip by -\singlespaceskip
  203. \kern \baselineskip}%
  204. \baselineskip=\singlespaceskip
  205. }
  206.  
  207. %% Simple single-character @ commands
  208.  
  209. % @@ prints an @
  210. % Kludge this until the fonts are right (grr).
  211. \def\@{{\tt \char '100}}
  212.  
  213. % Define @` and @' to be the same as ` and '
  214. % but suppressing ligatures.
  215. \def\`{{`}}
  216. \def\'{{'}}
  217.  
  218. % Used to generate quoted braces.
  219.  
  220. \def\mylbrace {{\tt \char '173}}
  221. \def\myrbrace {{\tt \char '175}}
  222. \let\{=\mylbrace
  223. \let\}=\myrbrace
  224.  
  225. % @: forces normal size whitespace following.
  226. \def\:{\spacefactor=1000 }
  227.  
  228. % @* forces a line break.
  229. \def\*{\hfil\break}
  230.  
  231. % @. is an end-of-sentence period.
  232. \def\.{.\spacefactor=3000 }
  233.  
  234. % @w prevents a word break
  235. \def\w #1{\hbox{#1}}
  236.  
  237. % @group ... @end group  forces ... to be all on one page.
  238.  
  239. \def\group{\begingroup% \inENV ???
  240. \def \Egroup{\egroup\endgroup}
  241. \vbox\bgroup}
  242.  
  243. % @need space-in-mils
  244. % forces a page break if there is not space-in-mils remaining.
  245.  
  246. \newdimen\mil  \mil=0.001in
  247.  
  248. \def\need{\parsearg\needx}
  249.  
  250. \def\needx #1{\par %
  251. \begingroup %
  252. \dimen0=\pagetotal %
  253. \advance \dimen0 by #1\mil %
  254. \ifdim \dimen0>\pagegoal \vfill\eject \fi %
  255. \endgroup}
  256.  
  257.  
  258. % @br   forces paragraph break
  259.  
  260. \let\br = \par
  261.  
  262. % @dots{}  output some dots
  263.  
  264. \def\dots{$\ldots$}
  265.  
  266. % @page    forces the start of a new page
  267.  
  268. \def\page{\par\vfill\supereject}
  269.  
  270. % @exdent text....
  271. % outputs text on separate line in roman font, starting at standard page margin
  272.  
  273. \def\exdent{\errmessage{@exdent in filled text}}
  274.   % @lisp, etc, define \exdent locally from \internalexdent
  275.  
  276. {\obeyspaces
  277. \gdef\internalexdent{\parsearg\exdentzzz}}
  278.  
  279. \def\exdentzzz #1{{\advance \leftskip by -\lispnarrowing
  280. \advance \hsize by -\leftskip
  281. \advance \hsize by -\rightskip
  282. \leftline{{\rm#1}}}}
  283.  
  284. % @include file    insert text of that file as input.
  285.  
  286. \def\include{\parsearg\includezzz}
  287. \def\includezzz #1{{\def\thisfile{#1}\input #1
  288. }}
  289.  
  290. \def\thisfile{}
  291.  
  292. % @center line   outputs that line, centered
  293.  
  294. \def\center{\parsearg\centerzzz}
  295. \def\centerzzz #1{{\advance\hsize by -\leftskip
  296. \advance\hsize by -\rightskip
  297. \centerline{#1}}}
  298.  
  299. % @sp n   outputs n lines of vertical space
  300.  
  301. \def\sp{\parsearg\spxxx}
  302. \def\spxxx #1{\par \vskip #1\baselineskip}
  303.  
  304. % @comment ...line which is ignored...
  305. % @c is the same as @comment
  306. % @ignore ... @end ignore  is another way to write a comment
  307.  
  308. \def\comment{\parsearg \commentxxx}
  309.  
  310. \def\commentxxx #1{}
  311.  
  312. \let\c=\comment
  313.  
  314. % Prevent errors for section commands.
  315. % Used in @ignore and in failing conditionals.
  316. \def\ignoresections{%
  317. \let\chapter=\relax
  318. \let\unnumbered=\relax
  319. \let\unnumberedsec=\relax
  320. \let\unnumberedsection=\relax
  321. \let\unnumberedsubsec=\relax
  322. \let\unnumberedsubsection=\relax
  323. \let\unnumberedsubsubsec=\relax
  324. \let\unnumberedsubsubsection=\relax
  325. \let\section=\relax
  326. \let\subsec=\relax
  327. \let\subsubsec=\relax
  328. \let\subsection=\relax
  329. \let\subsubsection=\relax
  330. \let\appendix=\relax
  331. \let\appendixsec=\relax
  332. \let\appendixsection=\relax
  333. \let\appendixsubsec=\relax
  334. \let\appendixsubsection=\relax
  335. \let\appendixsubsubsec=\relax
  336. \let\appendixsubsubsection=\relax
  337. }
  338.  
  339. \def\ignore{\begingroup\ignoresections\ignorexxx}
  340. \long\def\ignorexxx #1\end ignore{\endgroup\ignorespaces}
  341.  
  342. % Conditionals to test whether a flag is set.
  343.  
  344. \outer\def\ifset{\begingroup\ignoresections\parsearg\ifsetxxx}
  345.  
  346. \def\ifsetxxx #1{\endgroup
  347. \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\ifsetfail
  348. \else \let\temp=\relax \fi
  349. \temp}
  350. \def\Eifset{}
  351. \def\ifsetfail{\begingroup\ignoresections\ifsetfailxxx}
  352. \long\def\ifsetfailxxx #1\end ifset{\endgroup\ignorespaces}
  353.  
  354. \outer\def\ifclear{\begingroup\ignoresections\parsearg\ifclearxxx}
  355.  
  356. \def\ifclearxxx #1{\endgroup
  357. \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\relax
  358. \else \let\temp=\ifclearfail \fi
  359. \temp}
  360. \def\Eifclear{}
  361. \def\ifclearfail{\begingroup\ignoresections\ifclearfailxxx}
  362. \long\def\ifclearfailxxx #1\end ifclear{\endgroup\ignorespaces}
  363.  
  364. % Some texinfo constructs that are trivial in tex
  365.  
  366. \def\iftex{}
  367. \def\Eiftex{}
  368. \def\ifinfo{\begingroup\ignoresections\ifinfoxxx}
  369. \long\def\ifinfoxxx #1\end ifinfo{\endgroup\ignorespaces}
  370.  
  371. \long\def\menu #1\end menu{}
  372. \def\asis#1{#1}
  373.  
  374. \def\node{\ENVcheck\parsearg\nodezzz}
  375. \def\nodezzz#1{\nodexxx [#1,]}
  376. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  377. \let\lastnode=\relax
  378.  
  379. \def\donoderef{\ifx\lastnode\relax\else
  380. \expandafter\expandafter\expandafter\setref{\lastnode}\fi
  381. \let\lastnode=\relax}
  382.  
  383. \def\unnumbnoderef{\ifx\lastnode\relax\else
  384. \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
  385. \let\lastnode=\relax}
  386.  
  387. \def\appendixnoderef{\ifx\lastnode\relax\else
  388. \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
  389. \let\lastnode=\relax}
  390.  
  391. \let\refill=\relax
  392.   
  393. % @setfilename is done at the beginning of every texinfo file.
  394. % So open here the files we need to have open while reading the input.
  395. % This makes it possible to make a .fmt file for texinfo.
  396. \def\setfilename{%
  397.    \readauxfile
  398.    \opencontents
  399.    \openindices
  400.    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
  401.    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  402.    \comment % Ignore the actual filename.
  403. }
  404.  
  405. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  406.  
  407. \def\inforef #1{\inforefzzz #1,,,,**}
  408. \def\inforefzzz #1,#2,#3,#4**{See Info file \file{\losespace#3{}}, node `\losespace#1{}'}
  409. \def\losespace #1{#1}
  410.  
  411. \message{fonts,}
  412.  
  413. % Font-change commands.
  414.  
  415. %% Try out Computer Modern fonts at \magstephalf
  416. \font\tenrm=cmr10 scaled \magstephalf
  417. \font\tentt=cmtt10 scaled \magstephalf
  418. % Instead of cmb10, you many want to use cmbx10.
  419. % cmbx10 is a prettier font on its own, but cmb10
  420. % looks better when embedded in a line with cmr10.
  421. \font\tenbf=cmb10 scaled \magstephalf 
  422. \font\tenit=cmti10 scaled \magstephalf
  423. \font\tensl=cmsl10 scaled \magstephalf
  424. \font\tensf=cmss10 scaled \magstephalf
  425. \def\li{\sf}
  426. \font\tensc=cmcsc10 scaled \magstephalf
  427.  
  428. % Fonts for @defun, etc.
  429. \font\defbf=cmbx10 scaled \magstep1 %was 1314
  430. \font\deftt=cmtt10 scaled \magstep1
  431. \def\df{\let\tt=\deftt \defbf}
  432.  
  433. % Font for title
  434. % There seems to have been a confusion: two definitions of this font.
  435. % It is not clear why, or which one is better.
  436. \font\titlerm = cmbx10 scaled \magstep5
  437. % this is too small -- rms, May 1990.
  438. %\font\titlerm = cmbx12 scaled \magstep2
  439.  
  440. % Fonts for indices and small examples.
  441. % We actually use the slanted font rather than the italic, 
  442. % because texinfo normally uses the slanted fonts for that.
  443. \font\ninett=cmtt9
  444. \font\indit=cmsl9 \font\indrm=cmr9
  445. \let\indtt=\ninett
  446. \def\indbf{\indrm} \def\indsl{\indit}
  447. \def\indexfonts{\let\it=\indit \let\sl=\indsl \let\bf=\indbf \let\rm=\indrm
  448. \let\tt=\indtt}
  449.  
  450. % Fonts for headings
  451. \font\chaprm=cmbx10 scaled \magstep3
  452. \font\chapit=cmti10 scaled \magstep3
  453. \font\chapsl=cmsl10 scaled \magstep3
  454. \font\chaptt=cmtt10 scaled \magstep3
  455. \font\chapsf=cmss10 scaled \magstep3
  456. \let\chapbf=\chaprm
  457.  
  458. \font\secrm=cmbx10 scaled \magstep2
  459. \font\secit=cmti10 scaled \magstep2
  460. \font\secsl=cmsl10 scaled \magstep2
  461. \font\sectt=cmtt10 scaled \magstep2
  462. \font\secsf=cmss10 scaled \magstep2
  463. \let\secbf=\secrm
  464.  
  465. % \font\ssecrm=cmbx10 scaled \magstep1    % This size an fontlooked bad.
  466. % \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
  467. % \font\ssecsl=cmsl10 scaled \magstep1
  468. % \font\ssectt=cmtt10 scaled \magstep1
  469. % \font\ssecsf=cmss10 scaled \magstep1
  470.  
  471. \font\ssecrm=cmb10 scaled 1315  % Note the use of cmb rather than cmbx.
  472. \font\ssecit=cmti10 scaled 1315 % Also, the size is a little larger than
  473. \font\ssecsl=cmsl10 scaled 1315 % being scaled magstep1.
  474. \font\ssectt=cmtt10 scaled 1315
  475. \font\ssecsf=cmss10 scaled 1315
  476.  
  477. \let\ssecbf=\ssecrm
  478.  
  479. \def\textfonts{\let\rm=\tenrm\let\it=\tenit\let\sl=\tensl\let\bf=\tenbf%
  480. \let\smallcaps=\tensc\let\sf=\tensf}
  481. \def\chapfonts{\let\rm=\chaprm\let\it=\chapit\let\sl=\chapsl\let\bf=\chapbf\let\tt=\chaptt\let\sf=\chapsf}
  482. \def\secfonts{\let\rm=\secrm\let\it=\secit\let\sl=\secsl\let\bf=\secbf\let\tt=\sectt\let\sf=\secsf}
  483. \def\subsecfonts{\let\rm=\ssecrm\let\it=\ssecit\let\sl=\ssecsl\let\bf=\ssecbf\let\tt=\ssectt\let\sf=\ssecsf}
  484. % Count depth in font-changes, for error checks
  485. \newcount\fontdepth \fontdepth=0
  486.  
  487. % Font for table of contents.
  488. \font\truesecrm=cmr12
  489.  
  490. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  491. %% serif) and @ii for TeX italic
  492.  
  493. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  494. % unless the following character is such as not to need one.
  495. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  496. \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
  497.  
  498. \let\i=\smartitalic
  499. \let\var=\smartitalic
  500. \let\dfn=\smartitalic
  501. \let\emph=\smartitalic
  502. \let\cite=\smartitalic
  503.  
  504. \def\b#1{{\bf #1}}
  505. \let\strong=\b
  506.  
  507. \def\t#1{{\tt \rawbackslash \frenchspacing #1}\null}
  508. \let\ttfont = \t
  509. %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
  510. \def\samp #1{`\tclose{#1}'\null}
  511. \def\key #1{{\tt \uppercase{#1}}\null}
  512. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  513.  
  514. \let\file=\samp
  515.  
  516. % @code is a modification of @t,
  517. % which makes spaces the same size as normal in the surrounding text.
  518. \newdimen\tclosesave
  519. \newdimen\tcloserm
  520. \def\tclose#1{{\rm \tcloserm=\fontdimen2\font \tt \tclosesave=\fontdimen2\font
  521. \fontdimen2\font=\tcloserm
  522. \def\ {{\fontdimen2\font=\tclosesave{} }}%
  523.  \rawbackslash \frenchspacing #1\fontdimen2\font=\tclosesave}\null}
  524. \let\code=\tclose
  525. %\let\exp=\tclose  %Was temporary
  526.  
  527. % @kbd is like @code, except that if the argument is just one @key command, 
  528. % then @kbd has no effect.
  529.  
  530. \def\xkey{\key}
  531. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  532. \ifx\one\xkey\ifx\threex\three \key{#2}%
  533. \else\tclose{\look}\fi
  534. \else\tclose{\look}\fi}
  535.  
  536. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  537.  
  538. \def\l#1{{\li #1}\null}         % 
  539.  
  540. \def\r#1{{\rm #1}}              % roman font
  541. \def\sc#1{{\smallcaps #1}}      % smallcaps font
  542. \def\ii#1{{\it #1}}             % italic font
  543.  
  544. \message{page headings,}
  545.  
  546. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  547. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  548.  
  549. % First the title page.  Must do @settitle before @titlepage.
  550. \def\titlefont#1{{\titlerm #1}}
  551.  
  552. \newtoks\realeverypar
  553. \newif\ifseenauthor
  554. \newif\iffinishedtitlepage
  555.  
  556. \def\titlepage{\begingroup \parindent=0pt \textfonts
  557.    \let\subtitlerm=\tenrm
  558.    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  559.    %
  560.    \font\authorrm = cmbx12 scaled \magstep1
  561.    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  562.    %
  563.    % Leave some space at the very top of the page.
  564.    \vglue\titlepagetopglue
  565.    %
  566.    % Now you can print the title using @title.
  567.    \def\title{\parsearg\titlezzz}%
  568.    \def\titlezzz##1{\leftline{\titlefont{##1}}
  569.                     % print a rule at the page bottom also.
  570.                     \finishedtitlepagefalse
  571.                     \vskip4pt \hrule height 4pt \vskip4pt}%
  572.    % No rule at page bottom unless we print one at the top with @title.
  573.    \finishedtitlepagetrue
  574.    %
  575.    % Now you can put text using @subtitle.
  576.    \def\subtitle{\parsearg\subtitlezzz}%
  577.    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  578.    %
  579.    % @author should come last, but may come many times.
  580.    \def\author{\parsearg\authorzzz}%
  581.    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  582.       {\authorfont \leftline{##1}}}%
  583.    %  
  584.    % Most title ``pages'' are actually two pages long, with space
  585.    % at the top of the second.  We don't want the ragged left on the second.
  586.    \let\oldpage = \page
  587.    \def\page{%
  588.       \finishtitlepage
  589.       \oldpage
  590.       \let\page = \oldpage
  591.       \hbox{}}%
  592. %   \def\page{\oldpage \hbox{}}
  593. }
  594.  
  595. \def\Etitlepage{%
  596.    \iffinishedtitlepage\else
  597.       \finishtitlepage
  598.    \fi
  599.    \endgroup\page\HEADINGSon
  600. }
  601.  
  602. \def\finishtitlepage{%
  603.    \vskip4pt \hrule height 2pt
  604.    \vskip\titlepagebottomglue
  605.    \finishedtitlepagetrue
  606. }
  607.  
  608. %%% Set up page headings and footings.
  609.  
  610. \let\thispage=\folio
  611.  
  612. \newtoks \evenheadline    % Token sequence for heading line of even pages
  613. \newtoks \oddheadline     % Token sequence for heading line of odd pages
  614. \newtoks \evenfootline    % Token sequence for footing line of even pages
  615. \newtoks \oddfootline     % Token sequence for footing line of odd pages
  616.  
  617. % Now make Tex use those variables
  618. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}}
  619. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline \else \the\evenfootline \fi}}
  620.  
  621. % Commands to set those variables.
  622. % For example, this is what  @headings on  does
  623. % @evenheading @thistitle|@thispage|@thischapter
  624. % @oddheading @thischapter|@thispage|@thistitle
  625. % @evenfooting @thisfile||
  626. % @oddfooting ||@thisfile
  627.  
  628. \def\evenheading{\parsearg\evenheadingxxx}
  629. \def\oddheading{\parsearg\oddheadingxxx}
  630. \def\everyheading{\parsearg\everyheadingxxx}
  631.  
  632. \def\evenfooting{\parsearg\evenfootingxxx}
  633. \def\oddfooting{\parsearg\oddfootingxxx}
  634. \def\everyfooting{\parsearg\everyfootingxxx}
  635.  
  636. {\catcode`\@=0 %
  637.  
  638. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  639. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  640. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  641.  
  642. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  643. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  644. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  645.  
  646. \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
  647. \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
  648. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  649. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  650.  
  651. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  652. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  653. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  654.  
  655. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  656. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  657. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  658.  
  659. \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
  660. \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
  661. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  662. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  663. %
  664. }% unbind the catcode of @.
  665.  
  666. % @headings double      turns headings on for double-sided printing.
  667. % @headings single      turns headings on for single-sided printing.
  668. % @headings off         turns them off.
  669. % @headings on          same as @headings double, retained for compatibility.
  670. % By default, they are off.
  671.  
  672. \def\headings #1 {\csname HEADINGS#1\endcsname}
  673.  
  674. \def\HEADINGSoff{
  675. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  676. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  677. \HEADINGSoff
  678. % When we turn headings on, set the page number to 1.
  679. % For double-sided printing, put current file name in lower left corner,
  680. % chapter name on inside top of right hand pages, document
  681. % title on inside top of left hand pages, and page numbers on outside top
  682. % edge of all pages.
  683. \def\HEADINGSdouble{
  684. %\pagealignmacro
  685. \global\pageno=1
  686. \global\evenfootline={\hfil}
  687. \global\oddfootline={\hfil}
  688. \global\evenheadline={\line{\folio\hfil\thistitle}}
  689. \global\oddheadline={\line{\thischapter\hfil\folio}}
  690. }
  691. % For single-sided printing, chapter title goes across top left of page,
  692. % page number on top right.
  693. \def\HEADINGSsingle{
  694. %\pagealignmacro
  695. \global\pageno=1
  696. \global\evenfootline={\hfil}
  697. \global\oddfootline={\hfil}
  698. \global\evenheadline={\line{\thischapter\hfil\folio}}
  699. \global\oddheadline={\line{\thischapter\hfil\folio}}
  700. }
  701. \def\HEADINGSon{\HEADINGSdouble}
  702.  
  703. % Subroutines used in generating headings
  704. % Produces Day Month Year style of output.
  705. \def\today{\number\day\space
  706. \ifcase\month\or
  707. January\or February\or March\or April\or May\or June\or
  708. July\or August\or September\or October\or November\or December\fi
  709. \space\number\year}
  710.  
  711. % Use this if you want the Month Day, Year style of output.
  712. %\def\today{\ifcase\month\or
  713. %January\or February\or March\or April\or May\or June\or
  714. %July\or August\or September\or October\or November\or December\fi
  715. %\space\number\day, \number\year}
  716.  
  717. % @settitle line...  specifies the title of the document, for headings
  718. % It generates no output of its own
  719.  
  720. \def\thistitle{No Title}
  721. \def\settitle{\parsearg\settitlezzz}
  722. \def\settitlezzz #1{\gdef\thistitle{#1}}
  723.  
  724. \message{tables,}
  725.  
  726. % @tabs -- simple alignment
  727.  
  728. % These don't work.  For one thing, \+ is defined as outer.
  729. % So these macros cannot even be defined.
  730.  
  731. %\def\tabs{\parsearg\tabszzz}
  732. %\def\tabszzz #1{\settabs\+#1\cr}
  733. %\def\tabline{\parsearg\tablinezzz}
  734. %\def\tablinezzz #1{\+#1\cr}
  735. %\def\&{&}
  736.  
  737. % Tables -- @table, @ftable, @item(x), @kitem(x), @xitem(x).
  738.  
  739. % default indentation of table text
  740. \newdimen\tableindent \tableindent=.8in
  741. % default indentation of @itemize and @enumerate text
  742. \newdimen\itemindent  \itemindent=.3in
  743. % margin between end of table item and start of table text.
  744. \newdimen\itemmargin  \itemmargin=.1in
  745.  
  746. % used internally for \itemindent minus \itemmargin
  747. \newdimen\itemmax
  748.  
  749. % Note @table and @ftable define @item, @itemx, etc., with these defs.
  750. % They also define \itemindex
  751. % to index the item name in whatever manner is desired (perhaps none).
  752.  
  753. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  754. \def\internalBitemx{\par \parsearg\itemzzz}
  755.  
  756. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  757. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz}
  758.  
  759. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  760. \def\internalBkitemx{\par \parsearg\kitemzzz}
  761.  
  762. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}\itemzzz {#1}}
  763.  
  764. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}\itemzzz {#1}}
  765.  
  766. \def\itemzzz #1{\begingroup %
  767. \advance \hsize by -\rightskip %
  768. \advance \hsize by -\leftskip %
  769. \setbox0=\hbox{\itemfont{#1}}%
  770. \itemindex{#1}%
  771. \parskip=0in %
  772. \noindent %
  773. \ifdim \wd0>\itemmax %
  774. \vadjust{\penalty 10000}%
  775. \hbox to \hsize{\hskip -\tableindent\box0\hss}\ %
  776. \else %
  777. \hbox to 0pt{\hskip -\tableindent\box0\hss}%
  778. \fi %
  779. \endgroup %
  780. }
  781.  
  782. \def\item{\errmessage{@item while not in a table}}
  783. \def\itemx{\errmessage{@itemx while not in a table}}
  784. \def\kitem{\errmessage{@kitem while not in a table}}
  785. \def\kitemx{\errmessage{@kitemx while not in a table}}
  786. \def\xitem{\errmessage{@xitem while not in a table}}
  787. \def\xitemx{\errmessage{@xitemx while not in a table}}
  788.  
  789. %% Contains a kludge to get @end[description] to work
  790. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  791.  
  792. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  793. {\obeylines\obeyspaces%
  794. \gdef\tablex #1^^M{%
  795. \tabley\dontindex#1        \endtabley}}
  796.  
  797. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  798. {\obeylines\obeyspaces%
  799. \gdef\ftablex #1^^M{%
  800. \tabley\fnitemindex#1        \endtabley}}
  801.  
  802. \def\dontindex #1{}
  803. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  804.  
  805. {\obeyspaces %
  806. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  807. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  808.  
  809. \def\tablez #1#2#3#4#5#6{%
  810. \aboveenvbreak %
  811. \begingroup %
  812. \def\Edescription{\Etable}% Neccessary kludge.
  813. \let\itemindex=#1%
  814. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  815. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  816. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  817. \def\itemfont{#2}%
  818. \itemmax=\tableindent %
  819. \advance \itemmax by -\itemmargin %
  820. \advance \leftskip by \tableindent %
  821. \parindent = 0pt
  822. \parskip = \smallskipamount
  823. \ifdim \parskip=0pt \parskip=2pt \fi%
  824. \def\Etable{\endgraf\endgroup\afterenvbreak}%
  825. \let\item = \internalBitem %
  826. \let\itemx = \internalBitemx %
  827. \let\kitem = \internalBkitem %
  828. \let\kitemx = \internalBkitemx %
  829. \let\xitem = \internalBxitem %
  830. \let\xitemx = \internalBxitemx %
  831. }
  832.  
  833. % This is the counter used by @enumerate, which is really @itemize
  834.  
  835. \newcount \itemno
  836.  
  837. \def\itemize{\parsearg\itemizezzz}
  838.  
  839. \def\itemizezzz #1{\itemizey {#1}{\Eitemize}}
  840.  
  841. \def\itemizey #1#2{%
  842. \aboveenvbreak %
  843. \begingroup %
  844. \itemno = 0 %
  845. \itemmax=\itemindent %
  846. \advance \itemmax by -\itemmargin %
  847. \advance \leftskip by \itemindent %
  848. \parindent = 0pt
  849. \parskip = \smallskipamount
  850. \ifdim \parskip=0pt \parskip=2pt \fi%
  851. \def#2{\endgraf\endgroup\afterenvbreak}%
  852. \def\itemcontents{#1}%
  853. \let\item=\itemizeitem}
  854.  
  855. \def\bullet{$\ptexbullet$}
  856. \def\minus{$-$}
  857.  
  858. % Set sfcode to normal for the chars that usually have another value.
  859. % These are `.?!:;,'
  860. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  861.   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  862.  
  863. \def\enumerate{\itemizey{\the\itemno.}\Eenumerate\flushcr}
  864.  
  865. % Definition of @item while inside @itemize.
  866.  
  867. \def\itemizeitem{%
  868. \advance\itemno by 1
  869. {\let\par=\endgraf \smallbreak}%
  870. \ifhmode \errmessage{\in hmode at itemizeitem}\fi
  871. {\parskip=0in \hskip 0pt
  872. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  873. \vadjust{\penalty 300}}%
  874. \flushcr}
  875.  
  876. \message{indexing,}
  877. % Index generation facilities
  878.  
  879. % Define \newwrite to be identical to plain tex's \newwrite
  880. % except not \outer, so it can be used within \newindex.
  881. {\catcode`\@=11
  882. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  883.  
  884. % \newindex {foo} defines an index named foo.
  885. % It automatically defines \fooindex such that
  886. % \fooindex ...rest of line... puts an entry in the index foo.
  887. % It also defines \fooindfile to be the number of the output channel for
  888. % the file that accumulates this index.  The file's extension is foo.
  889. % The name of an index should be no more than 2 characters long
  890. % for the sake of vms.
  891.  
  892. \def\newindex #1{
  893. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  894. \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
  895. \expandafter\xdef\csname#1index\endcsname{%     % Define \xxxindex
  896. \noexpand\doindex {#1}}
  897. }
  898.  
  899. % @defindex foo  ==  \newindex{foo}
  900.  
  901. \def\defindex{\parsearg\newindex}
  902.  
  903. % Define @defcodeindex, like @defindex except put all entries in @code.
  904.  
  905. \def\newcodeindex #1{
  906. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  907. \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
  908. \expandafter\xdef\csname#1index\endcsname{%     % Define \xxxindex
  909. \noexpand\docodeindex {#1}}
  910. }
  911.  
  912. \def\defcodeindex{\parsearg\newcodeindex}
  913.  
  914. % @synindex foo bar    makes index foo feed into index bar.
  915. % Do this instead of @defindex foo if you don't want it as a separate index.
  916. \def\synindex #1 #2 {%
  917. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  918. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  919. \expandafter\xdef\csname#1index\endcsname{%     % Define \xxxindex
  920. \noexpand\doindex {#2}}%
  921. }
  922.  
  923. % @syncodeindex foo bar   similar, but put all entries made for index foo
  924. % inside @code.
  925. \def\syncodeindex #1 #2 {%
  926. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  927. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  928. \expandafter\xdef\csname#1index\endcsname{%     % Define \xxxindex
  929. \noexpand\docodeindex {#2}}%
  930. }
  931.  
  932. % Define \doindex, the driver for all \fooindex macros.
  933. % Argument #1 is generated by the calling \fooindex macro,
  934. %  and it is "foo", the name of the index.
  935.  
  936. % \doindex just uses \parsearg; it calls \doind for the actual work.
  937. % This is because \doind is more useful to call from other macros.
  938.  
  939. % There is also \dosubind {index}{topic}{subtopic}
  940. % which makes an entry in a two-level index such as the operation index.
  941.  
  942. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  943. \def\singleindexer #1{\doind{\indexname}{#1}}
  944.  
  945. % like the previous two, but they put @code around the argument.
  946. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  947. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  948.  
  949. \def\indexdummies{%
  950. \def\w{\realbackslash w }%
  951. \def\bf{\realbackslash bf }%
  952. \def\rm{\realbackslash rm }%
  953. \def\sl{\realbackslash sl }%
  954. \def\sf{\realbackslash sf}%
  955. \def\tt{\realbackslash tt}%
  956. \def\gtr{\realbackslash gtr}%
  957. \def\less{\realbackslash less}%
  958. \def\hat{\realbackslash hat}%
  959. \def\char{\realbackslash char}%
  960. \def\TeX{\realbackslash TeX}%
  961. \def\dots{\realbackslash dots }%
  962. \def\copyright{\realbackslash copyright }%
  963. \def\tclose##1{\realbackslash tclose {##1}}%
  964. \def\code##1{\realbackslash code {##1}}%
  965. \def\samp##1{\realbackslash samp {##1}}%
  966. \def\r##1{\realbackslash r {##1}}%
  967. \def\i##1{\realbackslash i {##1}}%
  968. \def\b##1{\realbackslash b {##1}}%
  969. \def\cite##1{\realbackslash cite {##1}}%
  970. \def\key##1{\realbackslash key {##1}}%
  971. \def\file##1{\realbackslash file {##1}}%
  972. \def\var##1{\realbackslash var {##1}}%
  973. \def\kbd##1{\realbackslash kbd {##1}}%
  974. }
  975.  
  976. % \indexnofonts no-ops all font-change commands.
  977. % This is used when outputting the strings to sort the index by.
  978. \def\indexdummyfont#1{#1}
  979. \def\indexnofonts{%
  980. \let\w=\indexdummyfont
  981. \let\r=\indexdummyfont
  982. \let\i=\indexdummyfont
  983. \let\b=\indexdummyfont
  984. \let\emph=\indexdummyfont
  985. \let\strong=\indexdummyfont
  986. \let\cite=\indexdummyfont
  987. \let\sc=\indexdummyfont
  988. %Don't no-op \tt, since it isn't a user-level command
  989. % and is used in the definitions of the actuve chars like <, >, |...
  990. %\let\tt=\indexdummyfont
  991. \let\tclose=\indexdummyfont
  992. \let\code=\indexdummyfont
  993. \let\file=\indexdummyfont
  994. \let\samp=\indexdummyfont
  995. \let\kbd=\indexdummyfont
  996. \let\key=\indexdummyfont
  997. \let\var=\indexdummyfont
  998. }
  999.  
  1000. % To define \realbackslash, we must make \ not be an escape.
  1001. % We must first make another character (@) an escape
  1002. % so we do not become unable to do a definition.
  1003.  
  1004. {\catcode`\@=0 \catcode`\\=\other
  1005. @gdef@realbackslash{\}}
  1006.  
  1007. \let\indexbackslash=0  %overridden during \printindex.
  1008.  
  1009. \def\doind #1#2{%
  1010. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1011. \count10=\lastpenalty %
  1012. \escapechar=`\\%
  1013. {\let\folio=0% Expand all macros now EXCEPT \folio
  1014. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  1015. % so it will be output as is; and it will print as backslash in the indx.
  1016. %
  1017. % Now process the index-string once, with all font commands turned off,
  1018. % to get the string to sort the index by.
  1019. {\indexnofonts
  1020. \xdef\temp1{#2}%
  1021. }%
  1022. % Now produce the complete index entry.  We process the index-string again,
  1023. % this time with font commands expanded, to get what to print in the index.
  1024. \edef\temp{%
  1025. \write \csname#1indfile\endcsname{%
  1026. \realbackslash entry {\temp1}{\folio}{#2}}}%
  1027. \temp }%
  1028. \penalty\count10}}
  1029.  
  1030. \def\dosubind #1#2#3{%
  1031. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1032. \count10=\lastpenalty %
  1033. \escapechar=`\\%
  1034. {\let\folio=0%
  1035. \def\rawbackslashxx{\indexbackslash}%
  1036. %
  1037. % Now process the index-string once, with all font commands turned off,
  1038. % to get the string to sort the index by.
  1039. {\indexnofonts
  1040. \xdef\temp1{#2 #3}%
  1041. }%
  1042. % Now produce the complete index entry.  We process the index-string again,
  1043. % this time with font commands expanded, to get what to print in the index.
  1044. \edef\temp{%
  1045. \write \csname#1indfile\endcsname{%
  1046. \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
  1047. \temp }%
  1048. \penalty\count10}}
  1049.  
  1050. % The index entry written in the file actually looks like
  1051. %  \entry {sortstring}{page}{topic}
  1052. % or
  1053. %  \entry {sortstring}{page}{topic}{subtopic}
  1054. % The texindex program reads in these files and writes files
  1055. % containing these kinds of lines:
  1056. %  \initial {c}
  1057. %     before the first topic whose initial is c
  1058. %  \entry {topic}{pagelist}
  1059. %     for a topic that is used without subtopics
  1060. %  \primary {topic}
  1061. %     for the beginning of a topic that is used with subtopics
  1062. %  \secondary {subtopic}{pagelist}
  1063. %     for each subtopic.
  1064.  
  1065. % Define the user-accessible indexing commands 
  1066. % @findex, @vindex, @kindex, @cindex.
  1067.  
  1068. \def\findex {\fnindex}
  1069. \def\kindex {\kyindex}
  1070. \def\cindex {\cpindex}
  1071. \def\vindex {\vrindex}
  1072. \def\tindex {\tpindex}
  1073. \def\pindex {\pgindex}
  1074.  
  1075. \def\cindexsub {\begingroup\obeylines\cindexsub}
  1076. {\obeylines %
  1077. \gdef\cindexsub "#1" #2^^M{\endgroup %
  1078. \dosubind{cp}{#2}{#1}}}
  1079.  
  1080. % Define the macros used in formatting output of the sorted index material.
  1081.  
  1082. % This is what you call to cause a particular index to get printed.
  1083. % Write
  1084. % @unnumbered Function Index
  1085. % @printindex fn
  1086.  
  1087. \def\printindex{\parsearg\doprintindex}
  1088.  
  1089. \def\doprintindex#1{\tex %
  1090. \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
  1091. \catcode`\$=\other\catcode`\_=\other
  1092. \catcode`\~=\other
  1093. % The following don't help, since the chars were translated
  1094. % when the raw index was written, and their fonts were discarded
  1095. % due to \indexnofonts.
  1096. %\catcode`\"=\active
  1097. %\catcode`\^=\active
  1098. %\catcode`\_=\active
  1099. %\catcode`\|=\active
  1100. %\catcode`\<=\active
  1101. %\catcode`\>=\active
  1102. \def\indexbackslash{\rawbackslashxx}
  1103. \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
  1104. \begindoublecolumns
  1105. \openin 1 \jobname.#1s
  1106. \ifeof 1 \else \closein 1 \input \jobname.#1s
  1107. \fi
  1108. \enddoublecolumns
  1109. \Etex}
  1110.  
  1111. % These macros are used by the sorted index file itself.
  1112. % Change them to control the appearance of the index.
  1113.  
  1114. % Same as \bigskipamount except no shrink.
  1115. % \balancecolumns gets confused if there is any shrink.
  1116. \newskip\initialskipamount \initialskipamount 12pt plus4pt
  1117.  
  1118. \outer\def\initial #1{%
  1119. {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  1120. \ifdim\lastskip<\initialskipamount
  1121. \removelastskip \penalty-200 \vskip \initialskipamount\fi
  1122. \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
  1123.  
  1124. \outer\def\entry #1#2{
  1125. {\parfillskip=0in \parskip=0in \parindent=0in
  1126. \hangindent=1in \hangafter=1%
  1127. \noindent\hbox{#1}\dotfill #2\par
  1128. }}
  1129.  
  1130. \def\primary #1{\line{#1\hfil}}
  1131.  
  1132. \newskip\secondaryindent \secondaryindent=0.5cm
  1133.  
  1134. \def\secondary #1#2{
  1135. {\parfillskip=0in \parskip=0in
  1136. \hangindent =1in \hangafter=1
  1137. \noindent\hskip\secondaryindent\hbox{#1}\dotfill #2\par
  1138. }}
  1139.  
  1140. %% Define two-column mode, which is used in indexes.
  1141. %% Adapted from the TeXBook, page 416
  1142. \catcode `\@=11
  1143.  
  1144. \newbox\partialpage
  1145.  
  1146. \newdimen\doublecolumnhsize  \doublecolumnhsize = 3.11in
  1147. \newdimen\doublecolumnvsize  \doublecolumnvsize = 19.1in
  1148. \newdimen\availdimen@
  1149.  
  1150. \def\begindoublecolumns{\begingroup
  1151.   \output={\global\setbox\partialpage=\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}\eject
  1152.   \output={\doublecolumnout} \hsize=\doublecolumnhsize \vsize=\doublecolumnvsize}
  1153. \def\enddoublecolumns{\output={\balancecolumns}\eject
  1154.   \endgroup \pagegoal=\vsize}
  1155.  
  1156. \def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  1157.   \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1158.   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1159.   \onepageout\pagesofar \unvbox255 \penalty\outputpenalty}
  1160. \def\pagesofar{\unvbox\partialpage %
  1161.   \hsize=\doublecolumnhsize % have to restore this since output routine
  1162. %             changes it to set cropmarks (P. A. MacKay, 12 Nov. 1986)
  1163.   \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
  1164. \def\balancecolumns{%
  1165. % Unset the glue.
  1166.   \setbox255=\vbox{\unvbox255}
  1167.   \dimen@=\ht255
  1168.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1169.   \divide\dimen@ by2
  1170.   \availdimen@=\pageheight \advance\availdimen@ by-\ht\partialpage
  1171. % If the remaining data is too big for one page,
  1172. % output one page normally, then work with what remains.
  1173.   \ifdim \dimen@>\availdimen@
  1174.    {
  1175.      \splittopskip=\topskip \splitmaxdepth=\maxdepth
  1176.      \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1177.      \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1178.      \onepageout\pagesofar
  1179.    }
  1180. % Recompute size of what remains, in case we just output some of it.
  1181.   \dimen@=\ht255
  1182.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1183.   \divide\dimen@ by2
  1184.   \fi
  1185.   \setbox0=\vbox{\unvbox255}
  1186.   \splittopskip=\topskip
  1187.   {\vbadness=10000 \loop \global\setbox3=\copy0
  1188.     \global\setbox1=\vsplit3 to\dimen@
  1189.     \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat}
  1190.   \setbox0=\vbox to\dimen@{\unvbox1}  \setbox2=\vbox to\dimen@{\unvbox3}
  1191.   \pagesofar}
  1192.  
  1193. \catcode `\@=\other
  1194. \message{sectioning,}
  1195. % Define chapters, sections, etc.
  1196.  
  1197. \newcount \chapno
  1198. \newcount \secno
  1199. \newcount \subsecno
  1200. \newcount \subsubsecno
  1201.  
  1202. % This counter is funny since it counts through charcodes of letters A, B, ...
  1203. \newcount \appendixno  \appendixno = `\@
  1204. \def\appendixletter{\char\the\appendixno}
  1205.  
  1206. \newwrite \contentsfile
  1207. % This is called from \setfilename.
  1208. \def\opencontents{\openout \contentsfile = \jobname.toc}
  1209.  
  1210. % Each @chapter defines this as the name of the chapter.
  1211. % page headings and footings can use it.  @section does likewise
  1212.  
  1213. \def\thischapter{} \def\thissection{}
  1214. \def\seccheck#1{\if \pageno<0 %
  1215. \errmessage{@#1 not allowed after generating table of contents}\fi
  1216. %
  1217. }
  1218.  
  1219. \def\chapternofonts{%
  1220. \let\rawbackslash=\relax%
  1221. \let\frenchspacing=\relax%
  1222. \def\TeX{\realbackslash TeX}
  1223. \def\dots{\realbackslash dots}
  1224. \def\copyright{\realbackslash copyright}
  1225. \def\tt{\realbackslash tt}
  1226. \def\bf{\realbackslash bf }
  1227. \def\w{\realbackslash w}
  1228. \def\less{\realbackslash less}
  1229. \def\gtr{\realbackslash gtr}
  1230. \def\hat{\realbackslash hat}
  1231. \def\char{\realbackslash char}
  1232. \def\tclose##1{\realbackslash tclose {##1}}
  1233. \def\code##1{\realbackslash code {##1}}
  1234. \def\samp##1{\realbackslash samp {##1}}
  1235. \def\r##1{\realbackslash r {##1}}
  1236. \def\b##1{\realbackslash b {##1}}
  1237. \def\key##1{\realbackslash key {##1}}
  1238. \def\file##1{\realbackslash file {##1}}
  1239. \def\kbd##1{\realbackslash kbd {##1}}
  1240. % These are redefined because @smartitalic wouldn't work inside xdef.
  1241. \def\i##1{\realbackslash i {##1}}
  1242. \def\cite##1{\realbackslash cite {##1}}
  1243. \def\var##1{\realbackslash var {##1}}
  1244. \def\emph##1{\realbackslash emph {##1}}
  1245. \def\dfn##1{\realbackslash dfn {##1}}
  1246. }
  1247.  
  1248. \outer\def\chapter{\parsearg\chapterzzz}
  1249. \def\chapterzzz #1{\seccheck{chapter}%
  1250. \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \chapno by 1 \message{Chapter \the\chapno}%
  1251. \chapmacro {#1}{\the\chapno}%
  1252. \gdef\thissection{#1}%
  1253. \gdef\thischaptername{#1}%
  1254. % We don't substitute the actual chapter name into \thischapter
  1255. % because we don't want its macros evaluated now.
  1256. \xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}%
  1257. {\chapternofonts%
  1258. \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
  1259. \escapechar=`\\%
  1260. \write \contentsfile \temp  %
  1261. \donoderef %
  1262. }}
  1263.  
  1264. \outer\def\appendix{\parsearg\appendixzzz}
  1265. \def\appendixzzz #1{\seccheck{appendix}%
  1266. \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
  1267. \chapmacro {#1}{Appendix \appendixletter}%
  1268. \gdef\thissection{#1}%
  1269. \gdef\thischaptername{#1}%
  1270. \xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}%
  1271. {\chapternofonts%
  1272. \edef\temp{{\realbackslash chapentry {#1}{Appendix \appendixletter}{\noexpand\folio}}}%
  1273. \escapechar=`\\%
  1274. \write \contentsfile \temp  %
  1275. \appendixnoderef %
  1276. }}
  1277.  
  1278. \outer\def\unnumbered{\parsearg\unnumberedzzz}
  1279. \def\unnumberedzzz #1{\seccheck{unnumbered}%
  1280. \secno=0 \subsecno=0 \subsubsecno=0 \message{(#1)}
  1281. \unnumbchapmacro {#1}%
  1282. \gdef\thischapter{#1}\gdef\thissection{#1}%
  1283. {\chapternofonts%
  1284. \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
  1285. \escapechar=`\\%
  1286. \write \contentsfile \temp  %
  1287. \unnumbnoderef %
  1288. }}
  1289.  
  1290. \outer\def\section{\parsearg\sectionzzz}
  1291. \def\sectionzzz #1{\seccheck{section}%
  1292. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1293. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  1294. {\chapternofonts%
  1295. \edef\temp{{\realbackslash secentry %
  1296. {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
  1297. \escapechar=`\\%
  1298. \write \contentsfile \temp %
  1299. \donoderef %
  1300. \penalty 10000 %
  1301. }}
  1302.  
  1303. \outer\def\appendixsection{\parsearg\appendixsectionzzz}
  1304. \outer\def\appendixsec{\parsearg\appendixsectionzzz}
  1305. \def\appendixsectionzzz #1{\seccheck{appendixsection}%
  1306. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1307. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  1308. {\chapternofonts%
  1309. \edef\temp{{\realbackslash secentry %
  1310. {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
  1311. \escapechar=`\\%
  1312. \write \contentsfile \temp %
  1313. \appendixnoderef %
  1314. \penalty 10000 %
  1315. }}
  1316.  
  1317. \outer\def\unnumberedsec{\parsearg\unnumberedseczzz}
  1318. \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
  1319. \plainsecheading {#1}\gdef\thissection{#1}%
  1320. {\chapternofonts%
  1321. \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
  1322. \escapechar=`\\%
  1323. \write \contentsfile \temp %
  1324. \unnumbnoderef %
  1325. \penalty 10000 %
  1326. }}
  1327.  
  1328. \outer\def\subsection{\parsearg\subsectionzzz}
  1329. \def\subsectionzzz #1{\seccheck{subsection}%
  1330. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1331. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  1332. {\chapternofonts%
  1333. \edef\temp{{\realbackslash subsecentry %
  1334. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1335. \escapechar=`\\%
  1336. \write \contentsfile \temp %
  1337. \donoderef %
  1338. \penalty 10000 %
  1339. }}
  1340.  
  1341. \outer\def\appendixsubsec{\parsearg\appendixsubseczzz}
  1342. \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
  1343. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1344. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  1345. {\chapternofonts%
  1346. \edef\temp{{\realbackslash subsecentry %
  1347. {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1348. \escapechar=`\\%
  1349. \write \contentsfile \temp %
  1350. \appendixnoderef %
  1351. \penalty 10000 %
  1352. }}
  1353.  
  1354. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1355. \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
  1356. \plainsecheading {#1}\gdef\thissection{#1}%
  1357. {\chapternofonts%
  1358. \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
  1359. \escapechar=`\\%
  1360. \write \contentsfile \temp %
  1361. \unnumbnoderef %
  1362. \penalty 10000 %
  1363. }}
  1364.  
  1365. \outer\def\subsubsection{\parsearg\subsubsectionzzz}
  1366. \def\subsubsectionzzz #1{\seccheck{subsubsection}%
  1367. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1368. \subsubsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1369. {\chapternofonts%
  1370. \edef\temp{{\realbackslash subsubsecentry %
  1371. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
  1372. \escapechar=`\\%
  1373. \write \contentsfile \temp %
  1374. \donoderef %
  1375. \penalty 10000 %
  1376. }}
  1377.  
  1378. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1379. \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
  1380. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1381. \subsubsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1382. {\chapternofonts%
  1383. \edef\temp{{\realbackslash subsubsecentry{#1}%
  1384. {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
  1385. \escapechar=`\\%
  1386. \write \contentsfile \temp %
  1387. \appendixnoderef %
  1388. \penalty 10000 %
  1389. }}
  1390.  
  1391. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1392. \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
  1393. \plainsecheading {#1}\gdef\thissection{#1}%
  1394. {\chapternofonts%
  1395. \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
  1396. \escapechar=`\\%
  1397. \write \contentsfile \temp %
  1398. \unnumbnoderef %
  1399. \penalty 10000 %
  1400. }}
  1401.  
  1402. % These are variants which are not "outer", so they can appear in @ifinfo.
  1403. \def\infounnumbered{\parsearg\unnumberedzzz}
  1404. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  1405. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1406. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1407.  
  1408. \def\infoappendix{\parsearg\appendixzzz}
  1409. \def\infoappendixsec{\parsearg\appendixseczzz}
  1410. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  1411. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1412.  
  1413. \def\infochapter{\parsearg\chapterzzz}
  1414. \def\infosection{\parsearg\sectionzzz}
  1415. \def\infosubsection{\parsearg\subsectionzzz}
  1416. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  1417.  
  1418. % Define @majorheading, @heading and @subheading
  1419.  
  1420. \def\majorheading #1{%
  1421. {\advance\chapheadingskip by 10pt \chapbreak }%
  1422. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 200}
  1423.  
  1424. \def\chapheading #1{\chapbreak %
  1425. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 200}
  1426.  
  1427. \def\heading{\parsearg\secheadingi}
  1428.  
  1429. % These macros generate a chapter, section, etc. heading only
  1430. % (including whitespace, linebreaking, etc. around it),
  1431. % given all the information in convenient, parsed form.
  1432.  
  1433. %%% Args are the skip and penalty (usually negative)
  1434. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  1435.  
  1436. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  1437.  
  1438. %%% Define plain chapter starts, and page on/off switching for it
  1439. % Parameter controlling skip before chapter headings (if needed)
  1440.  
  1441. \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
  1442.  
  1443. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  1444. \def\chappager{\par\vfill\supereject}
  1445. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  1446.  
  1447. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  1448.  
  1449. \def\CHAPPAGoff{
  1450. \global\let\pchapsepmacro=\chapbreak
  1451. \global\let\pagealignmacro=\chappager}
  1452.  
  1453. \def\CHAPPAGon{
  1454. \global\let\pchapsepmacro=\chappager
  1455. \global\let\pagealignmacro=\chappager
  1456. \global\def\HEADINGSon{\HEADINGSsingle}}
  1457.  
  1458. \def\CHAPPAGodd{
  1459. \global\let\pchapsepmacro=\chapoddpage
  1460. \global\let\pagealignmacro=\chapoddpage
  1461. \global\def\HEADINGSon{\HEADINGSdouble}}
  1462.  
  1463. \CHAPPAGon
  1464.  
  1465. \def\CHAPFplain{
  1466. \global\let\chapmacro=\chfplain
  1467. \global\let\unnumbchapmacro=\unnchfplain}
  1468.  
  1469. \def\chfplain #1#2{%
  1470. \pchapsepmacro %
  1471. {\chapfonts \line{\rm #2.\enspace #1\hfill}}\bigskip \par\penalty 5000 %
  1472. }
  1473.  
  1474. \def\unnchfplain #1{%
  1475. \pchapsepmacro %
  1476. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 10000 %
  1477. }
  1478. \CHAPFplain % The default
  1479.  
  1480. \def\unnchfopen #1{%
  1481. \chapoddpage {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 10000 %
  1482. }
  1483.  
  1484. \def\chfopen #1#2{\chapoddpage {\chapfonts
  1485. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  1486. \par\penalty 5000 %
  1487. }
  1488.  
  1489. \def\CHAPFopen{
  1490. \global\let\chapmacro=\chfopen
  1491. \global\let\unnumbchapmacro=\unnchfopen}
  1492.  
  1493. % Parameter controlling skip before section headings.
  1494.  
  1495. \newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
  1496. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  1497.  
  1498. \newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
  1499. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  1500.  
  1501.  
  1502. % Section fonts are the base font at magstep2, which produces
  1503. % a size a bit more than 14 points in the default situation.    
  1504.  
  1505. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
  1506. \def\plainsecheading #1{\secheadingi {#1}}
  1507. \def\secheadingi #1{{\advance \secheadingskip by \parskip %
  1508. \secheadingbreak}%
  1509. {\secfonts \line{\rm #1\hfill}}%
  1510. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1511.  
  1512.  
  1513. % Subsection fonts are the base font at magstep1, 
  1514. % which produces a size of 12 points.
  1515.  
  1516. \def\subsecheading #1#2#3#4{{\advance \subsecheadingskip by \parskip %
  1517. \subsecheadingbreak}%
  1518. {\subsecfonts \line{\rm#2.#3.#4\enspace #1\hfill}}%
  1519. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1520.  
  1521. \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
  1522.                                   % Perhaps make sssec fonts scaled
  1523.                                   % magstep half
  1524. \def\subsubsecheading #1#2#3#4#5{{\advance \subsecheadingskip by \parskip %
  1525. \subsecheadingbreak}%
  1526. {\subsubsecfonts \line{\rm#2.#3.#4.#5\enspace #1\hfill}}%
  1527. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
  1528.  
  1529.  
  1530. \message{toc printing,}
  1531.  
  1532. % Finish up the main text and prepare to read what we've written
  1533. % to \contentsfile.
  1534.  
  1535. \def\startcontents#1{%
  1536.    \ifnum \pageno>0
  1537.       \pagealignmacro
  1538.       \immediate\closeout \contentsfile
  1539.       \pageno = -1              % Request roman numbered pages.
  1540.    \fi
  1541.    % Don't need to put `Contents' or `Short Contents' in the headline. 
  1542.    % It is abundantly clear what they are.
  1543.    \unnumbchapmacro{#1}\def\thischapter{}%
  1544.    \begingroup                  % Set up to handle contents files properly.
  1545.       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
  1546.       \raggedbottom             % Worry more about breakpoints than the bottom.
  1547.       \advance\hsize by -1in    % Don't use the full line length.
  1548. }
  1549.  
  1550.   
  1551. % Normal (long) toc.
  1552. \outer\def\contents{%
  1553.    \startcontents{Table of Contents}%
  1554.       \input \jobname.toc
  1555.    \endgroup
  1556.    \vfill \eject
  1557. }
  1558.  
  1559. % And just the chapters.
  1560. \outer\def\summarycontents{%
  1561.    \startcontents{Short Contents}%
  1562.       %
  1563.       \let\chapentry = \shortchapentry
  1564.       \let\unnumbchapentry = \shortunnumberedentry
  1565.       % We want a true roman here for the page numbers.
  1566.       \secfonts \let\rm = \truesecrm \rm
  1567.       \advance\baselineskip by 1pt % Open it up a little.
  1568.       \def\secentry ##1##2##3##4{}
  1569.       \def\unnumbsecentry ##1##2{}
  1570.       \def\subsecentry ##1##2##3##4##5{}
  1571.       \def\unnumbsubsecentry ##1##2{}
  1572.       \def\subsubsecentry ##1##2##3##4##5##6{}
  1573.       \def\unnumbsubsubsecentry ##1##2{}
  1574.       \input \jobname.toc
  1575.    \endgroup
  1576.    \vfill \eject
  1577. }
  1578. \let\shortcontents = \summarycontents
  1579.  
  1580. % These macros generate individual entries in the table of contents.
  1581. % The first argument is the chapter or section name.
  1582. % The last argument is the page number.
  1583. % The arguments in between are the chapter number, section number, ...
  1584.  
  1585. % Chapter-level things, for both the long and short contents.
  1586. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  1587. \def\shortchapentry#1#2#3{%
  1588.    \line{{#2\labelspace #1}\dotfill\doshortpageno{#3}}%
  1589. }
  1590.  
  1591. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  1592. \def\shortunnumberedentry#1#2{%
  1593.    \line{#1\dotfill\doshortpageno{#2}}%
  1594. }
  1595.  
  1596. % Sections.
  1597. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  1598. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  1599.  
  1600. % Subsections.
  1601. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  1602. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  1603.  
  1604. % And subsubsections.
  1605. \def\subsubsecentry#1#2#3#4#5#6{\dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  1606. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  1607.  
  1608.  
  1609. % This parameter controls the indentation of the various levels.
  1610. \newdimen\tocindent \tocindent = 3pc
  1611.  
  1612. % Now for the actual typesetting. In all these, #1 is the text and #2 is the 
  1613. % page number.
  1614. %
  1615. % If the toc has to be broken over pages, we would want to be at chapters 
  1616. % if at all possible; hence the \penalty.
  1617. \def\dochapentry#1#2{%
  1618.    \penalty-300 \vskip\baselineskip
  1619.    \line{\chapentryfonts #1\dotfill \dopageno{#2}}%
  1620.    \nobreak\vskip .25\baselineskip
  1621. }
  1622.  
  1623. \def\dosecentry#1#2{%
  1624.    \line{\secentryfonts \hskip\tocindent #1\dotfill \dopageno{#2}}%
  1625. }
  1626.  
  1627. \def\dosubsecentry#1#2{%
  1628.    \line{\subsecentryfonts \hskip2\tocindent #1\dotfill \dopageno{#2}}%
  1629. }
  1630.  
  1631. \def\dosubsubsecentry#1#2{%
  1632.    \line{\subsubsecentryfonts \hskip3\tocindent #1\dotfill \dopageno{#2}}%
  1633. }
  1634.  
  1635. % Space between chapter (or whatever) number and the title.
  1636. \def\labelspace{\hskip1em \relax}
  1637.  
  1638. \def\dopageno#1{{\rm #1}}
  1639. \def\doshortpageno#1{{\rm #1}}
  1640.  
  1641. \def\chapentryfonts{\secfonts \rm}
  1642. \def\secentryfonts{\textfonts}
  1643. \let\subsecentryfonts = \textfonts
  1644. \let\subsubsecentryfonts = \textfonts
  1645.  
  1646.  
  1647. \message{environments,}
  1648.  
  1649. % Since these characters are used in examples, it should be an even number of 
  1650. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  1651. % Furthermore, these definitions must come after we define our fonts.
  1652. \newbox\dblarrowbox    \newbox\longdblarrowbox
  1653. \newbox\pushcharbox    \newbox\bullbox
  1654. \newbox\equivbox       \newbox\errorbox
  1655.  
  1656. \let\ptexequiv = \equiv
  1657.  
  1658. {\tentt
  1659. \global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  1660. \global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  1661. \global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  1662. \global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  1663. % Adapted from the manmac format (p.420 of TeXbook)
  1664. \global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  1665.                                       depth .1ex\hfil}
  1666. }
  1667.  
  1668. \def\point{$\star$}
  1669.  
  1670. \def\result{\leavevmode\raise.15ex\copy\dblarrowbox}
  1671. \def\expansion{\leavevmode\raise.1ex\copy\longdblarrowbox}
  1672. \def\print{\leavevmode\lower.1ex\copy\pushcharbox}
  1673.  
  1674. \def\equiv{\leavevmode\lower.1ex\copy\equivbox}
  1675.  
  1676. % Does anyone really want this?
  1677. % \def\bull{\leavevmode\copy\bullbox}
  1678.  
  1679. % Adapted from the TeXbook's \boxit.
  1680. {\tentt \global\dimen0 = 3em}% Width of the box.
  1681. \dimen2 = .55pt % Thickness of rules
  1682. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  1683. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  1684.  
  1685. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  1686.    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  1687.    \advance\hsize by -2\dimen2 % Rules.
  1688.    \vbox{
  1689.       \hrule height\dimen2
  1690.       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
  1691.          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  1692.          \kern3pt\vrule width\dimen2}% Space to right.
  1693.       \hrule height\dimen2}
  1694.     \hfil}
  1695.  
  1696. % The @error{} command.
  1697. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  1698.  
  1699. % @tex ... @end tex    escapes into raw Tex temporarily.
  1700. % One exception: @ is still an escape character, so that @end tex works.
  1701. % But \@ or @@ will get a plain tex @ character.
  1702.  
  1703. \def\tex{\begingroup
  1704. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  1705. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  1706. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  1707. \catcode `\%=14
  1708. \catcode`\"=12
  1709. \catcode`\==12
  1710. \catcode`\|=12
  1711. \catcode`\<=12
  1712. \catcode`\>=12
  1713. \escapechar=`\\
  1714. %
  1715. \let\{=\ptexlbrace
  1716. \let\}=\ptexrbrace
  1717. \let\.=\ptexdot
  1718. \let\*=\ptexstar
  1719. \def\@={@}%
  1720. \let\bullet=\ptexbullet
  1721. \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
  1722. \let\L=\ptexL
  1723. %
  1724. \let\Etex=\endgroup}
  1725.  
  1726. % Define @lisp ... @endlisp.
  1727. % @lisp does a \begingroup so it can rebind things,
  1728. % including the definition of @endlisp (which normally is erroneous).
  1729.  
  1730. % Amount to narrow the margins by for @lisp.
  1731. \newskip\lispnarrowing \lispnarrowing=0.4in
  1732.  
  1733. % This is the definition that ^M gets inside @lisp
  1734. % phr: changed space to \null, to avoid overfull hbox problems.
  1735. {\obeyspaces%
  1736. \gdef\lisppar{\null\endgraf}}
  1737.  
  1738. % Cause \obeyspaces to make each Space cause a word-separation
  1739. % rather than the default which is that it acts punctuation.
  1740. % This is because space in tt font looks funny.
  1741. {\obeyspaces %
  1742. \gdef\sepspaces{\def {\ }}}
  1743.  
  1744. \newskip\aboveenvskipamount \aboveenvskipamount= 0pt
  1745. \def\aboveenvbreak{{\advance\aboveenvskipamount by \parskip
  1746. \endgraf \ifdim\lastskip<\aboveenvskipamount
  1747. \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}}
  1748.  
  1749. \def\afterenvbreak{\endgraf \ifdim\lastskip<\aboveenvskipamount
  1750. \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}
  1751.  
  1752. \def\lisp{\aboveenvbreak\begingroup\inENV %This group ends at the end of the @lisp body
  1753. \hfuzz=12truept % Don't be fussy
  1754. % Make spaces be word-separators rather than space tokens.
  1755. \sepspaces %
  1756. % Single space lines
  1757. \singlespace %
  1758. % The following causes blank lines not to be ignored
  1759. % by adding a space to the end of each line.
  1760. \let\par=\lisppar
  1761. \def\Elisp{\endgroup\afterenvbreak}%
  1762. \parskip=0pt
  1763. \advance \leftskip by \lispnarrowing
  1764. \parindent=0pt
  1765. \let\exdent=\internalexdent
  1766. \obeyspaces \obeylines \tt \rawbackslash
  1767. \def\next##1{}\next}
  1768.  
  1769.  
  1770. \let\example=\lisp
  1771. \def\Eexample{\Elisp}
  1772.  
  1773. \let\smallexample=\lisp
  1774. \def\Esmallexample{\Elisp}
  1775.  
  1776. % Macro for 9 pt. examples, necessary to print with 5" lines.
  1777. % From Pavel@xerox.  This is not really used unless the
  1778. % @smallbook command is given.
  1779.  
  1780. \def\smalllispx{\aboveenvbreak\begingroup\inENV
  1781. %                       This group ends at the end of the @lisp body
  1782. \hfuzz=12truept % Don't be fussy
  1783. % Make spaces be word-separators rather than space tokens.
  1784. \sepspaces %
  1785. % Single space lines
  1786. \singlespace %
  1787. % The following causes blank lines not to be ignored
  1788. % by adding a space to the end of each line.
  1789. \let\par=\lisppar
  1790. \def\Esmalllisp{\endgroup\afterenvbreak}%
  1791. \parskip=0pt
  1792. \advance \leftskip by \lispnarrowing
  1793. \parindent=0pt
  1794. \let\exdent=\internalexdent
  1795. \obeyspaces \obeylines \ninett \indexfonts \rawbackslash
  1796. \def\next##1{}\next}
  1797.  
  1798. % This is @display; same as @lisp except use roman font.
  1799.  
  1800. \def\display{\begingroup\inENV %This group ends at the end of the @display body
  1801. \aboveenvbreak
  1802. % Make spaces be word-separators rather than space tokens.
  1803. \sepspaces %
  1804. % Single space lines
  1805. \singlespace %
  1806. % The following causes blank lines not to be ignored
  1807. % by adding a space to the end of each line.
  1808. \let\par=\lisppar
  1809. \def\Edisplay{\endgroup\afterenvbreak}%
  1810. \parskip=0pt
  1811. \advance \leftskip by \lispnarrowing
  1812. \parindent=0pt
  1813. \let\exdent=\internalexdent
  1814. \obeyspaces \obeylines
  1815. \def\next##1{}\next}
  1816.  
  1817. % This is @format; same as @lisp except use roman font and don't narrow margins
  1818.  
  1819. \def\format{\begingroup\inENV %This group ends at the end of the @format body
  1820. \aboveenvbreak
  1821. % Make spaces be word-separators rather than space tokens.
  1822. \sepspaces %
  1823. \singlespace %
  1824. % The following causes blank lines not to be ignored
  1825. % by adding a space to the end of each line.
  1826. \let\par=\lisppar
  1827. \def\Eformat{\endgroup\afterenvbreak}
  1828. \parskip=0pt \parindent=0pt
  1829. \obeyspaces \obeylines
  1830. \def\next##1{}\next}
  1831.  
  1832. % @flushleft and @flushright
  1833.  
  1834. \def\flushleft{\begingroup\inENV %This group ends at the end of the @format body
  1835. \aboveenvbreak
  1836. % Make spaces be word-separators rather than space tokens.
  1837. \sepspaces %
  1838. % The following causes blank lines not to be ignored
  1839. % by adding a space to the end of each line.
  1840. % This also causes @ to work when the directive name
  1841. % is terminated by end of line.
  1842. \let\par=\lisppar
  1843. \def\Eflushleft{\endgroup\afterenvbreak}%
  1844. \parskip=0pt \parindent=0pt
  1845. \obeyspaces \obeylines
  1846. \def\next##1{}\next}
  1847.  
  1848. \def\flushright{\begingroup\inENV %This group ends at the end of the @format body
  1849. \aboveenvbreak
  1850. % Make spaces be word-separators rather than space tokens.
  1851. \sepspaces %
  1852. % The following causes blank lines not to be ignored
  1853. % by adding a space to the end of each line.
  1854. % This also causes @ to work when the directive name
  1855. % is terminated by end of line.
  1856. \let\par=\lisppar
  1857. \def\Eflushright{\endgroup\afterenvbreak}%
  1858. \parskip=0pt \parindent=0pt
  1859. \advance \leftskip by 0pt plus 1fill
  1860. \obeyspaces \obeylines
  1861. \def\next##1{}\next}
  1862.  
  1863. % @quotation - narrow the margins.
  1864.  
  1865. \def\quotation{\begingroup\inENV %This group ends at the end of the @quotation body
  1866. {\parskip=0pt  % because we will skip by \parskip too, later
  1867. \aboveenvbreak}%
  1868. \singlespace
  1869. \parindent=0pt
  1870. \def\Equotation{\par\endgroup\afterenvbreak}%
  1871. \advance \rightskip by \lispnarrowing 
  1872. \advance \leftskip by \lispnarrowing}
  1873.  
  1874. \message{defuns,}
  1875. % Define formatter for defuns
  1876. % First, allow user to change definition object font (\df) internally
  1877. \def\setdeffont #1 {\csname DEF#1\endcsname}
  1878.  
  1879. \newskip\defbodyindent \defbodyindent=.4in
  1880. \newskip\defargsindent \defargsindent=50pt
  1881. \newskip\deftypemargin \deftypemargin=12pt
  1882. \newskip\deflastargmargin \deflastargmargin=18pt
  1883.  
  1884. \newcount\parencount
  1885. % define \functionparens, which makes ( and ) and & do special things.
  1886. % \functionparens affects the group it is contained in.
  1887. \def\activeparens{%
  1888. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  1889. \catcode`\[=\active \catcode`\]=\active}
  1890. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  1891. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  1892. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  1893.  
  1894. % Definitions of (, ) and & used in args for functions.
  1895. % This is the definition of ( outside of all parentheses.
  1896. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
  1897. \global\advance\parencount by 1 }
  1898. %
  1899. % This is the definition of ( when already inside a level of parens.
  1900. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  1901. %
  1902. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  1903. % also in that case restore the outer-level definition of (.
  1904. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  1905. \global\advance \parencount by -1 }
  1906. % If we encounter &foo, then turn on ()-hacking afterwards
  1907. \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
  1908. %
  1909. \gdef\normalparens{\boldbrax\let&=\ampnr}
  1910. } % End of definition inside \activeparens
  1911. %% These parens (in \boldbrax) actually are a little bolder than the
  1912. %% contained text.  This is especially needed for [ and ]
  1913. \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
  1914. \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
  1915.  
  1916. % First, defname, which formats the header line itself.
  1917. % #1 should be the function name.
  1918. % #2 should be the type of definition, such as "Function".
  1919.  
  1920. \def\defname #1#2{%
  1921. \leftskip = 0in  %
  1922. \noindent        %
  1923. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  1924. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  1925. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  1926. \parshape 2 0in \dimen0 \defargsindent \dimen1     %
  1927. % Now output arg 2 ("Function" or some such)
  1928. % ending at \deftypemargin from the right margin,
  1929. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  1930. \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}%
  1931. \tolerance=10000 \hbadness=10000    % Make all lines underfull and no complaints
  1932. {\df #1}\enskip        % Generate function name
  1933. }
  1934.  
  1935. % Actually process the body of a definition
  1936. % #1 should be the terminating control sequence, such as \Edefun.
  1937. % #2 should be the "another name" control sequence, such as \defunx.
  1938. % #3 should be the control sequence that actually processes the header,
  1939. %    such as \defunheader.
  1940.  
  1941. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  1942. \medbreak %
  1943. % Define the end token that this defining construct specifies
  1944. % so that it will exit this group.
  1945. \def#1{\endgraf\endgroup\medbreak}%
  1946. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  1947. \parindent=0in \leftskip=\defbodyindent \rightskip=\defbodyindent %
  1948. \begingroup %
  1949. \catcode 61=\active %
  1950. \obeylines\activeparens\spacesplit#3}
  1951.  
  1952. \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
  1953. \medbreak %
  1954. % Define the end token that this defining construct specifies
  1955. % so that it will exit this group.
  1956. \def#1{\endgraf\endgroup\medbreak}%
  1957. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  1958. \parindent=0in \leftskip=\defbodyindent \rightskip=\defbodyindent %
  1959. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  1960.  
  1961. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  1962. \medbreak %
  1963. % Define the end token that this defining construct specifies
  1964. % so that it will exit this group.
  1965. \def#1{\endgraf\endgroup\medbreak}%
  1966. \def#2##1 ##2 {\def#4{##1}%
  1967. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  1968. \parindent=0in \leftskip=\defbodyindent %
  1969. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  1970.  
  1971. % Split up #2 at the first space token.
  1972. % call #1 with two arguments:
  1973. %  the first is all of #2 before the space token,
  1974. %  the second is all of #2 after that space token.
  1975. % If #2 contains no space token, all of it is passed as the first arg
  1976. % and the second is passed as empty.
  1977.  
  1978. {\obeylines
  1979. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  1980. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  1981. \ifx\relax #3%
  1982. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  1983.  
  1984. % So much for the things common to all kinds of definitions.
  1985.  
  1986. % Define @defun.
  1987.  
  1988. % First, define the processing that is wanted for arguments of \defun
  1989. % Use this to expand the args and terminate the paragraph they make up
  1990.  
  1991. \def\defunargs #1{\functionparens \sl
  1992. % Expand, preventing hyphenation at `-' chars.
  1993. % Note that groups don't affect changes in \hyphenchar.
  1994. \hyphenchar\sl=0
  1995. #1%
  1996. \hyphenchar\sl=45
  1997. \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
  1998. \interlinepenalty=10000
  1999. \advance\rightskip by 0pt plus 1fil
  2000. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2001. }
  2002.  
  2003. % Do complete processing of one @defun or @defunx line already parsed.
  2004.  
  2005. % @deffn Command forward-char nchars
  2006.  
  2007. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  2008.  
  2009. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  2010. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  2011. \catcode 61=\other % Turn off change made in \defparsebody
  2012. }
  2013.  
  2014. % @defun == @deffn Function
  2015.  
  2016. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  2017.  
  2018. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2019. \begingroup\defname {#1}{Function}%
  2020. \defunargs {#2}\endgroup %
  2021. \catcode 61=\other % Turn off change made in \defparsebody
  2022. }
  2023.  
  2024. % @defmac == @deffn Macro
  2025.  
  2026. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  2027.  
  2028. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2029. \begingroup\defname {#1}{Macro}%
  2030. \defunargs {#2}\endgroup %
  2031. \catcode 61=\other % Turn off change made in \defparsebody
  2032. }
  2033.  
  2034. % @defspec == @deffn Special Form
  2035.  
  2036. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  2037.  
  2038. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2039. \begingroup\defname {#1}{Special Form}%
  2040. \defunargs {#2}\endgroup %
  2041. \catcode 61=\other % Turn off change made in \defparsebody
  2042. }
  2043.  
  2044. % This definition is run if you use @defunx
  2045. % anywhere other than immediately after a @defun or @defunx.
  2046.  
  2047. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  2048. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  2049. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  2050. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  2051.  
  2052. % @defmethod, and so on
  2053.  
  2054. % @defop {Funny Method} foo-class frobnicate argument
  2055.  
  2056. \def\defop #1 {\def\defoptype{#1}%
  2057. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  2058.  
  2059. \def\defopheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
  2060. \begingroup\defname {#2}{\defoptype{} on #1}%
  2061. \defunargs {#3}\endgroup %
  2062. }
  2063.  
  2064. % @defmethod == @defop Method
  2065.  
  2066. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  2067.  
  2068. \def\defmethodheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% entry in function index
  2069. \begingroup\defname {#2}{Operation on #1}%
  2070. \defunargs {#3}\endgroup %
  2071. }
  2072.  
  2073. % @defcv {Class Option} foo-class foo-flag
  2074.  
  2075. \def\defcv #1 {\def\defcvtype{#1}%
  2076. \defopparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
  2077.  
  2078. \def\defcvarheader #1#2#3{%
  2079. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2080. \begingroup\defname {#2}{\defcvtype{} of #1}%
  2081. \defvarargs {#3}\endgroup %
  2082. }
  2083.  
  2084. % @defivar == @defcv {Instance Variable}
  2085.  
  2086. \def\defivar{\defmethparsebody\Edefivar\defivarx\defivarheader}
  2087.  
  2088. \def\defivarheader #1#2#3{%
  2089. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2090. \begingroup\defname {#2}{Instance variable of #1}%
  2091. \defvarargs {#3}\endgroup %
  2092. }
  2093.  
  2094. % These definitions are run if you use @defmethodx, etc.,
  2095. % anywhere other than immediately after a @defmethod, etc.
  2096.  
  2097. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  2098. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  2099. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  2100. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  2101.  
  2102. % Now @defvar
  2103.  
  2104. % First, define the processing that is wanted for arguments of @defvar.
  2105. % This is actually simple: just print them in roman.
  2106. % This must expand the args and terminate the paragraph they make up
  2107. \def\defvarargs #1{\normalparens #1%
  2108. \interlinepenalty=10000
  2109. \endgraf\penalty 10000\vskip -\parskip\penalty 10000}
  2110.  
  2111. % @defvr Counter foo-count
  2112.  
  2113. \def\defvr{\defmethparsebody\Edefvr\defvrx\defvrheader}
  2114.  
  2115. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  2116. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  2117.  
  2118. % @defvar == @defvr Variable
  2119.  
  2120. \def\defvar{\defparsebody\Edefvar\defvarx\defvarheader}
  2121.  
  2122. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2123. \begingroup\defname {#1}{Variable}%
  2124. \defvarargs {#2}\endgroup %
  2125. }
  2126.  
  2127. % @defopt == @defvr {User Option}
  2128.  
  2129. \def\defopt{\defparsebody\Edefopt\defoptx\defoptheader}
  2130.  
  2131. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2132. \begingroup\defname {#1}{User Option}%
  2133. \defvarargs {#2}\endgroup %
  2134. }
  2135.  
  2136. % This definition is run if you use @defvarx
  2137. % anywhere other than immediately after a @defvar or @defvarx.
  2138.  
  2139. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  2140. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  2141. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  2142.  
  2143. % Now define @deftp
  2144. % Args are printed in bold, a slight difference from @defvar.
  2145.  
  2146. \def\deftpargs #1{\bf \defvarargs{#1}}
  2147.  
  2148. % @deftp Class window height width ...
  2149.  
  2150. \def\deftp{\defmethparsebody\Edeftp\deftpx\deftpheader}
  2151.  
  2152. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  2153. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  2154.  
  2155. % This definition is run if you use @deftpx, etc
  2156. % anywhere other than immediately after a @deftp, etc.
  2157.  
  2158. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  2159.  
  2160. \message{cross reference,}
  2161. % Define cross-reference macros
  2162. \newwrite \auxfile
  2163.  
  2164. \newif\ifhavexrefs  % True if xref values are known.
  2165. \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
  2166.  
  2167. % \setref{foo} defines a cross-reference point named foo.
  2168.  
  2169. \def\setref#1{%
  2170. \dosetq{#1-pg}{Ypagenumber}%
  2171. \dosetq{#1-snt}{Ysectionnumberandtype}}
  2172.  
  2173. \def\unnumbsetref#1{%
  2174. \dosetq{#1-pg}{Ypagenumber}%
  2175. \dosetq{#1-snt}{Ynothing}}
  2176.  
  2177. \def\appendixsetref#1{%
  2178. \dosetq{#1-pg}{Ypagenumber}%
  2179. \dosetq{#1-snt}{Yappendixletterandtype}}
  2180.  
  2181. % \xref and \pxref generate cross references to specified points.
  2182.  
  2183. \def\pxref #1{see \xrefX [#1,,,,,,,]}
  2184. \def\xref #1{See \xrefX [#1,,,,,,,]}
  2185. \def\ref #1{\xrefX [#1,,,,,,,]}
  2186. \def\xrefX [#1,#2,#3,#4,#5,#6]{%
  2187. {\setbox1=\hbox{\i{\losespace#5{}}}%
  2188. \setbox0=\hbox{\losespace#3{}}%
  2189. \ifdim \wd0 =0pt \setbox0=\hbox{\losespace#1{}}\fi%
  2190. \ifdim \wd1 >0pt%
  2191. section `\unhbox0' in \unhbox1%
  2192. \else%
  2193. \turnoffactive%
  2194. \refx{#1-snt}{} [\unhbox0], page\tie \refx{#1-pg}{}%
  2195. \fi }}
  2196.  
  2197. % \dosetq is the interface for calls from other macros
  2198.  
  2199. % Use \turnoffactive so that punctuation chars such as underscore
  2200. % work in node names.
  2201. \def\dosetq #1#2{{\let\folio=0 \turnoffactive%
  2202. \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
  2203. \next}}
  2204.  
  2205. % \internalsetq {foo}{page} expands into CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  2206. % When the aux file is read, ' is the escape character
  2207.  
  2208. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  2209.  
  2210. % Things to be expanded by \internalsetq
  2211.  
  2212. \def\Ypagenumber{\folio}
  2213.  
  2214. \def\Ynothing{}
  2215.  
  2216. \def\Ysectionnumberandtype{%
  2217. \ifnum\secno=0 Chapter\xreftie\the\chapno %
  2218. \else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno %
  2219. \else \ifnum \subsubsecno=0 %
  2220. Section\xreftie\the\chapno.\the\secno.\the\subsecno %
  2221. \else %
  2222. Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  2223. \fi \fi \fi }
  2224.  
  2225. \def\Yappendixletterandtype{%
  2226. \ifnum\secno=0 Appendix\xreftie'char\the\appendixno %
  2227. \else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno %
  2228. \else \ifnum \subsubsecno=0 %
  2229. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  2230. \else %
  2231. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  2232. \fi \fi \fi }
  2233.  
  2234. \gdef\xreftie{'tie}
  2235.  
  2236. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  2237. % If its value is nonempty, SUFFIX is output afterward.
  2238.  
  2239. \def\refx#1#2{%
  2240. {%
  2241. \expandafter\ifx\csname X#1\endcsname\relax
  2242. % If not defined, say something at least.
  2243. {$\langle$un\-def\-in\-ed$\rangle$}#2%
  2244. \ifhavexrefs
  2245. \message {WARNING: undefined cross-reference "#1"}%
  2246. \message {}%
  2247. \else
  2248. \ifwarnedxrefs
  2249. \else
  2250. \global\warnedxrefstrue
  2251. \message {WARNING: cross-references values are not known; you must run TeX a second time}%
  2252. \message {}%
  2253. \fi
  2254. \fi
  2255. \fi
  2256. \setbox0=\hbox{\csname X#1\endcsname}%It's defined, so just use it.
  2257. \ifdim\wd0>0pt \unhbox0{}#2\fi
  2258. }}
  2259.  
  2260. % Read the last existing aux file, if any.  No error if none exists.
  2261.  
  2262. % This is the macro invoked by entries in the aux file.
  2263. \def\xrdef #1#2{
  2264. {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
  2265.  
  2266. \def\readauxfile{%
  2267. \begingroup
  2268. \catcode `\^^@=\other
  2269. \catcode `\=\other
  2270. \catcode `\=\other
  2271. \catcode `\^^C=\other
  2272. \catcode `\^^D=\other
  2273. \catcode `\^^E=\other
  2274. \catcode `\^^F=\other
  2275. \catcode `\^^G=\other
  2276. \catcode `\^^H=\other
  2277. \catcode `\ =\other
  2278. \catcode `\^^L=\other
  2279. \catcode `\=\other
  2280. \catcode `\=\other
  2281. \catcode `\=\other
  2282. \catcode `\=\other
  2283. \catcode `\=\other
  2284. \catcode `\=\other
  2285. \catcode `\=\other
  2286. \catcode `\=\other
  2287. \catcode `\=\other
  2288. \catcode `\=\other
  2289. \catcode `\=\other
  2290. \catcode `\=\other
  2291. \catcode `\=\other
  2292. \catcode `\^^[=\other
  2293. \catcode `\^^\=\other
  2294. \catcode `\^^]=\other
  2295. \catcode `\^^^=\other
  2296. \catcode `\^^_=\other
  2297. \catcode `\@=\other
  2298. \catcode `\^=\other
  2299. \catcode `\~=\other
  2300. \catcode `\[=\other
  2301. \catcode `\]=\other
  2302. \catcode`\"=\other
  2303. \catcode`\_=\other
  2304. \catcode`\|=\other
  2305. \catcode`\<=\other
  2306. \catcode`\>=\other
  2307. \catcode `\$=\other
  2308. \catcode `\#=\other
  2309. \catcode `\&=\other
  2310. % the aux file uses ' as the escape.
  2311. % Turn off \ as an escape so we do not lose on
  2312. % entries which were dumped with control sequences in their names.
  2313. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  2314. % Reference to such entries still does not work the way one would wish,
  2315. % but at least they do not bomb out when the aux file is read in.
  2316. \catcode `\{=1 \catcode `\}=2
  2317. \catcode `\%=\other
  2318. \catcode `\'=0
  2319. \catcode `\\=\other
  2320. \openin 1 \jobname.aux
  2321. \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
  2322. \fi
  2323. % Open the new aux file.  Tex will close it automatically at exit.
  2324. \openout \auxfile=\jobname.aux
  2325. \endgroup}
  2326.  
  2327.  
  2328. % Footnotes.
  2329.  
  2330. \newcount \footnoteno
  2331.  
  2332. \def\supereject{\par\penalty -20000\footnoteno =0 }
  2333.  
  2334. \let\ptexfootnote=\footnote
  2335.  
  2336. {\catcode `\@=11
  2337. \long\gdef\footnote #1{\global\advance \footnoteno by \@ne
  2338. \edef\thisfootno{$^{\the\footnoteno}$}%
  2339. \let\@sf\empty
  2340. \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  2341. \thisfootno\@sf \footnotezzz{#1}}
  2342. % \parsearg\footnotezzz}
  2343.  
  2344. \long\gdef\footnotezzz #1{\insert\footins{
  2345. \interlinepenalty\interfootnotelinepenalty
  2346. \splittopskip\ht\strutbox % top baseline for broken footnotes
  2347. \splitmaxdepth\dp\strutbox \floatingpenalty\@MM
  2348. \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
  2349. \footstrut\hang\textindent{\thisfootno}#1\strut}}
  2350.  
  2351. }%end \catcode `\@=11
  2352.  
  2353. % End of control word definitions.
  2354.  
  2355. \message{and turning on texinfo input format.}
  2356.  
  2357. \def\openindices{%
  2358.    \newindex{cp}%
  2359.    \newcodeindex{fn}%
  2360.    \newcodeindex{vr}%
  2361.    \newcodeindex{tp}%
  2362.    \newcodeindex{ky}%
  2363.    \newcodeindex{pg}%
  2364. }
  2365.  
  2366. % Set some numeric style parameters, for 8.5 x 11 format.
  2367.  
  2368. %\hsize = 6.5in
  2369. \parindent 15pt
  2370. \parskip 18pt plus 1pt
  2371. \baselineskip 15pt
  2372. \advance\topskip by 1.2cm
  2373.  
  2374. % Prevent underfull vbox error messages.
  2375. \vbadness=10000
  2376.  
  2377. % Use @smallbook to reset parameters for 7x9.5 format
  2378. \def\smallbook{
  2379. \global\lispnarrowing = 0.3in
  2380. \global\baselineskip 12pt
  2381. \global\parskip 3pt plus 1pt
  2382. \global\hsize = 5in
  2383. \global\doublecolumnhsize=2.4in \global\doublecolumnvsize=15.0in
  2384. \global\vsize=7.5in
  2385. \global\tolerance=700
  2386. \global\hfuzz=1pt
  2387.  
  2388. \global\pagewidth=\hsize
  2389. \global\pageheight=\vsize
  2390.  
  2391. \global\let\smalllisp=\smalllispx
  2392. \global\let\smallexample=\smalllispx
  2393. \global\def\Esmallexample{\Esmalllisp}
  2394. }
  2395.  
  2396. %% For a final copy, take out the rectangles
  2397. %% that mark overfull boxes (in case you have decided
  2398. %% that the text looks ok even though it passes the margin).
  2399. \def\finalout{\overfullrule=0pt}
  2400.  
  2401. % Define macros to output various characters with catcode for normal text.
  2402. \catcode`\"=\other
  2403. \catcode`\~=\other
  2404. \catcode`\^=\other
  2405. \catcode`\_=\other
  2406. \catcode`\|=\other
  2407. \catcode`\<=\other
  2408. \catcode`\>=\other
  2409. \catcode`\+=\other
  2410. \def\normaldoublequote{"}
  2411. \def\normaltilde{~}
  2412. \def\normalcaret{^}
  2413. \def\normalunderscore{_}
  2414. \def\normalverticalbar{|}
  2415. \def\normalless{<}
  2416. \def\normalgreater{>}
  2417. \def\normalplus{+}
  2418.  
  2419. % Turn off all special characters except @
  2420. % (and those which the user can use as if they were ordinary)
  2421. % Define certain chars to be always in tt font.
  2422.  
  2423. \catcode`\"=\active
  2424. \def\activedoublequote{{\tt \char '042}}
  2425. \let"=\activedoublequote
  2426. \catcode`\~=\active
  2427. \def~{{\tt \char '176}}
  2428. \chardef\hat=`\^
  2429. \catcode`\^=\active
  2430. \def^{{\tt \hat}}
  2431. \catcode`\_=\active
  2432. \def_{{\tt \char '137}}
  2433. \catcode`\|=\active
  2434. \def|{{\tt \char '174}}
  2435. \chardef \less=`\<
  2436. \catcode`\<=\active
  2437. \def<{{\tt \less}}
  2438. \chardef \gtr=`\>
  2439. \catcode`\>=\active
  2440. \def>{{\tt \gtr}}
  2441. \catcode`\+=\active
  2442. \def+{{\tt \char 43}}
  2443. %\catcode 27=\active
  2444. %\def^^[{$\diamondsuit$}
  2445.  
  2446. % Used sometimes to turn off (effectively) the active characters
  2447. % even after parsing them.
  2448. \def\turnoffactive{\let"=\normaldoublequote
  2449. \let~=\normaltilde
  2450. \let^=\normalcaret
  2451. \let_=\normalunderscore
  2452. \let|=\normalverticalbar
  2453. \let<=\normalless
  2454. \let>=\normalgreater
  2455. \let+=\normalplus}
  2456.  
  2457. % Set up an active definition for =, but don't enable it most of the time.
  2458. {\catcode`\==\active
  2459. \global\def={{\tt \char 61}}}
  2460.  
  2461. \catcode`\@=0
  2462.  
  2463. % \rawbackslashxx output one backslash character in current font
  2464. \global\chardef\rawbackslashxx=`\\
  2465. %{\catcode`\\=\other
  2466. %@gdef@rawbackslashxx{\}}
  2467.  
  2468. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  2469. {\catcode`\\=\active
  2470. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  2471.  
  2472. % \normalbackslash outputs one backslash in fixed width font.
  2473. \def\normalbackslash{{\tt\rawbackslashxx}}
  2474.  
  2475. % Say @foo, not \foo, in error messages.
  2476. \escapechar=`\@
  2477.  
  2478. @c \catcode 17=0   @c Define control-q
  2479. \catcode`\\=\active
  2480.  
  2481. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  2482. % That is what \eatinput is for; after that, the `\' should revert to printing 
  2483. % a backslash.
  2484. %
  2485. @gdef@eatinput input texinfo{@fixbackslash}
  2486. @global@let\ = @eatinput
  2487.  
  2488. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  2489. % the first `\{ in the file would cause an error. This macro tries to fix 
  2490. % that, assuming it is called before the first `\' could plausibly occur.
  2491. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
  2492.  
  2493. %% These look ok in all fonts, so just make them not special.  The @rm below
  2494. %% makes sure that the current font starts out as the newly loaded cmr10
  2495. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  2496.  
  2497. @textfonts
  2498. @rm
  2499.